package com.example.socket.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Classname JsonExtractor
 * @Description TODO
 * @Date 2023/4/27 11:33
 * @Created by XiongXiong
 * @Author: X.I.O
 */
public class JsonExtractor {

   // private static String patternString = "\\{.*\\}";

    private static String patternString = "\\{[\\s\\S]*?\\}";

    private static  Pattern pattern = Pattern.compile(patternString);

    public static String getJsonString(String content){
        Matcher matcher = pattern.matcher(content);
        if (matcher.find()) {
            String json = matcher.group();
            return json;
        } else {
            System.out.println("No JSON found");
            return "";
        }
    }
}
